home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ 2⁄16⁄90 / 0690-Re BackGr BMaps 2nd -Feb90 < prev    next >
Encoding:
Text File  |  1990-02-16  |  2.7 KB  |  108 lines  |  [TEXT/GEOL]

  1. Item    9346392                         16-Feb-90        07:38PST
  2.  
  3. From:   KEMINK1                         Kemink, Joost
  4.  
  5. To:     BETA                            Beta, Edward Anuff,PRT
  6.  
  7. cc:     MACAPP.TECH$                    MacApp Technical
  8.  
  9. Sub:    Re BackGr BMaps 2nd try
  10.  
  11. Brett,
  12.  
  13. When I read my AppleLinks this morning, I was surprised to see my reply to you.
  14. I sent your question instead of my reply. That happens when sending links after
  15. midnight I guess. Anyway, apologies to you and the other MacAppers that may
  16. have received that link (I removed it).
  17.  
  18. Here is the link I intended to send.
  19.  
  20. I prefer to use MacApp's idle mechanism. It is easy to understand and only a
  21. few things have to be done to get it up and running. Below I have included the
  22. source code for a counter that counts backwards and displays its value, nothing
  23. fancy. As long as you remember to keep the execution of your idle chunks
  24. relatively short, the user won't experience any user interface latency.
  25.  
  26. You don't have to be afraid that your mouse 'freezes' while your idle task is
  27. executed, since mouse movement is handled by interrupts. These interrupts
  28. continue, even while you are execute your idle task.
  29.  
  30. Add the following code to the Nothing example, add a field fIdler to
  31. TNothingApplication and change INothingApplication as shown. This should give
  32. you something to experiment with.
  33.  
  34. TIdler = OBJECT(TEvtHandler)
  35.    fToGo   :   INTEGER;
  36.  
  37.    PROCEDURE TIdler.IIdler(initialValue:INTEGER);
  38.  
  39.    PROCEDURE TIdler.Install;
  40.    PROCEDURE TIdler.Remove;
  41.  
  42.    FUNCTION  TIdler.DoIdle(phase:IdlePhase):BOOLEAN; OVERRIDE;
  43.  
  44.    FUNCTION  TIdler.IsFinished:BOOLEAN;
  45. END;
  46.  
  47. PROCEDURE TIdler.IIdler(initialValue:INTEGER);
  48. BEGIN
  49.    SELF.IEvtHandler(NIL);
  50.  
  51.    SELF.fToGo:=initialValue;
  52.    SELF.fIdleFreq:=0;  { • Idle as often as possible }
  53. END;
  54.  
  55. FUNCTION TIdler.DoIdle(phase:IdlePhase):BOOLEAN; OVERRIDE;
  56. BEGIN
  57.    IF NOT SELF.IsFinished THEN
  58.    BEGIN
  59.    SELF.fToGo:=SELF.fToGo-1;
  60.    {$IFC qDebug}
  61.    Writeln('To Go: ',SELF.fToGo:1);
  62.    {$ENDC qDebug}
  63.    END;
  64.    IF SELF.IsFinished THEN
  65.    SELF.Remove;
  66.    DoIdle:=FALSE;
  67. END;
  68.  
  69. PROCEDURE TIdler.Install;
  70. BEGIN
  71.    gApplication.InstallCoHandler(SELF,TRUE);
  72. END;
  73.  
  74. PROCEDURE TIdler.Remove;
  75. BEGIN
  76.    gApplication.InstallCoHandler(SELF,FALSE);
  77. END;
  78.  
  79. FUNCTION  TIdler.IsFinished:BOOLEAN;
  80. BEGIN
  81.    IsFinished:=(SELF.fToGo<=0);
  82. END;
  83.  
  84. PROCEDURE TNothingApplication.INothingApplication(
  85.    itsMainFileType: OSType);
  86. VAR
  87.    anIdler :   TIdler;
  88. BEGIN
  89.    IApplication(itsMainFileType);
  90.  
  91.    RegisterStdType('TDefaultView', kStdDefaultView);
  92.    IF gDeadStripSuppression THEN
  93.    IF Member(TObject(NIL), TDefaultView) THEN ;
  94.  
  95.    New(anIdler);
  96.    FailNIL(anIdler);
  97.    anIdler.IIdler(30000);
  98.    SELF.fIdler:=anIdler;
  99.    anIdler.Install;
  100. END;
  101.  
  102. { ----- }
  103.  
  104. Hope this helps,
  105.  
  106. Joost Kemink
  107.  
  108.